var myTbContentId='mytbc1';
var myJqTbContentId='#'+myTbContentId;
var myTbId='myt1';
var myJqTbId='#'+myTbId;
var myPageId='myp1';
var myJqPageId='#'+myPageId;

$(function () {
	var id = $('#selectId').attr('data-id');
  var t1=$('<table></table>');
  t1.attr('id',myTbId);
  $(myJqTbContentId).append(t1);
  
  var p1=$('<div></div>');
  p1.attr('id',myPageId);
  
  p1.insertAfter(t1);
  
  
  $(myJqTbId).jqGrid({
      url: basePath+'providerBillPkg/'+id,
      mtype: "GET",
      datatype: "json",
      caption: "流量包列表",	//设置表标题
      page: 1,
      colNames: ['id', '省份','地市',  '话费包'],
      colModel: [
          { name: 'id', key: true, sortable: false,hidden:true },
          { name: 'province_code', sortable: false,index:'province_code' },
          { name: 'city_code', sortable: false,index:'city_code' },
          { name: 'name', sortable: false ,index:'name' }
      ],
      //width: 750,
      height: 'auto',
      autowidth:true,
      shrinkToFit:true,
      multiselect:true,//多选框
      multiboxonly:false,//为true时是单选
      hidegrid: false,	//隐藏表格右上角的"展开/收缩jqGrid内容的小箭头"
      autoScroll: false,
      rowNum : myRowNum,
      rowList : myRowList,
      viewrecords : true,//显示总记录数
      rownumbers: true,
      pager: myJqPageId
  });
  
  setTimeout(function(){
      $('.wrapper-content').removeClass('animated fadeInRight');
  },700);
  message();
  setMyActive(6,1); //设置激活页
});

function editEx(){
	var id =$("#providerId").val();
	var myBasePath=basePath+'providerBillPkgEditPage/'+id;
	location.href=myBasePath;
}

function del(ids){
	var id =$("#providerId").val();
	var delFlag=confirm("确认要删除么？");
	if(delFlag){
    	var myDelUrl=basePath+'providerBillPkg/'+ids;
		$.ajax({
    		type:'DELETE',
    		url :myDelUrl,
    		success:function (dt){
    			if(dt){
    				swal({
    	    	        title: "删除成功",
    	    	        type: "success",
    	    	        confirmButtonText: "ok"
    	    	    },
    				function(isConfirm){
    	    	    	location.href=basePath+'providerBillPkgList/'+id;
	    	        });
    			}else{
    				swal({
    	    	        title: "删除失败",
    	    	        type: "warning",
    	    	        confirmButtonText: "ok"
    	    	    },
    				function(isConfirm){
    	    	    	location.href=basePath+'providerBillPkgList/'+id;
	    	        });
    			}
    	    },
    	    error:function(dt){
				swal({
	    	        title: "系统异常!",
	    	        type: "warning",
	    	        confirmButtonText: "ok"
	    	    },function(isConfirm){
	    	    	location.href=basePath+'providerBillPkgList/'+id;
    	        });
	    },
    	    dataType: 'html'
    	});
	}
}

function delEx(){
	var ids=jQuery(myJqTbId).jqGrid("getGridParam", "selarrrow");
	if(ids==null){
		outMessage('warning','没有选中的记录！','友情提示');
	}else{
		del(ids);
	}
}

function search(){
	var id =$("#providerId").val();
	var provinceCode=$('#provinceCode').val();
	var cityCode=$('#cityCode').val();
	$(myJqTbId).jqGrid('setGridParam', {
		url : basePath + 'providerBillPkg/'+id,
		postData : {
			'provinceCode' : provinceCode,
			'cityCode' : cityCode
		},// 发送数据
		page : 1
	}).trigger("reloadGrid"); // 重新载入
}